// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   JTextFieldLimit.java

package com.boci.common.ui;

import javax.swing.text.*;

public class JTextFieldLimit extends PlainDocument
{

    public JTextFieldLimit(int limit)
    {
        toUppercase = false;
        this.limit = limit;
    }

    public JTextFieldLimit(int limit, boolean upper)
    {
        toUppercase = false;
        this.limit = limit;
        toUppercase = upper;
    }

    public void insertString(int offset, String str, AttributeSet attr)
        throws BadLocationException
    {
        if(str == null)
            return;
        if(getLength() + str.length() <= limit)
        {
            if(toUppercase)
                str = str.toUpperCase();
            super.insertString(offset, str, attr);
        }
    }

    private int limit;
    private boolean toUppercase;
}
